import 'package:flutter/material.dart';

class AnimationDemo extends StatefulWidget {
  const AnimationDemo({super.key});

  @override
  State<AnimationDemo> createState() => _AnimationDemoState();
}

class _AnimationDemoState extends State<AnimationDemo>
    with SingleTickerProviderStateMixin {
  late Animation<double> animation;
  late AnimationController controller;
  late AnimationStatus status;
  late double animationValue;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    controller = AnimationController(vsync: this, duration: Duration(seconds: 2));
    animation = Tween<double>(begin: 0, end: 300).animate(controller)
      ..addListener(() {
        setState(() {
          animationValue = animation.value;
        });
      });
    animation.addStatusListener((AnimationStatus status) {
      setState(() {
        this.status = status;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    var url =
        "https://ds1028.tocmcc.cn/QQ2022/Albums/%E5%85%B6%E4%BB%96/%E6%88%91%E7%9A%84%E7%9B%B8%E5%86%8C/032_2022-10-28_ACB78C9B.png";
    return Scaffold(
      appBar: AppBar(title: Text("Image 加载的方法")),
      body: Container(
        child: Wrap(
          spacing: 8,
          runSpacing: 6,
          children: [
            Image.network(url, height: 140),
            Image.asset('images/dan.jpg', height: 100),
          ],
        ),
      ),
    );
  }
}
